using MicroMsg.Common.Event;
using MicroMsg.Manager;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class BindedMobilePage : BasePage
	{
		private EventWatcher m_UnbindMobileOK;
		private EventWatcher m_UnbindMobileErr;
		internal Grid LayoutRoot;
		internal Grid ContentPanel;
		internal TextBlock txtBindedQQ;
		internal Button btnViewContacts;
		internal Button btnUnbind;
		private bool _contentLoaded;
		public BindedMobilePage()
		{
			this.InitializeComponent();
		}
		private void initData()
		{
			this.txtBindedQQ.set_Text(strings.Set_Mobile_Num + AccountMgr.strBindMobile);
		}
		private void btnViewContacts_Click(object sender, RoutedEventArgs e)
		{
			base.GoToPage("/Source/UI/PhoneContact/ViewPhoneContact.xaml", null, false);
		}
		private void btnUnbind_Click(object sender, RoutedEventArgs e)
		{
			MMMessageBox mMMessageBox = MMMessageBox.Show(strings.Set_Mobile_Unbind, strings.Set_Mobile_Unbing_Warning, true, strings.COM_Confirm, strings.COM_Cancel);
			mMMessageBox.ReturnEvent = new DlgReturnEvent(this.MsgBoxUnbindMobileHandler);
		}
		public void MsgBoxUnbindMobileHandler(DlgReturnEventArg dlgReturnEventArg_0)
		{
			switch (MMMessageBox.GetUserClickResult(dlgReturnEventArg_0))
			{
			case 0:
				this.showProgressCover(strings.Set_Mobile_Unbinding);
				ServiceCenter.sceneBindMobile.doSceneUnBindMobile(AccountMgr.strBindMobile);
				break;
			case 1:
				break;
			default:
				return;
			}
		}
		protected override void OnPageIn(object[] object_0)
		{
			this.initData();
			this.m_UnbindMobileOK = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventUnbindMobileOK));
			this.m_UnbindMobileErr = new EventWatcher(this, null, new EventHandlerDelegate(this.onEventUnbindMobileErr));
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_UNBINDMOBILE_SUCCESS, this.m_UnbindMobileOK);
			EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_UNBINDMOBILE_ERR, this.m_UnbindMobileErr);
		}
		protected override void OnPageOut()
		{
			if (this.m_UnbindMobileOK == null)
			{
				return;
			}
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_UNBINDMOBILE_SUCCESS, this.m_UnbindMobileOK);
			this.m_UnbindMobileOK = null;
			EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_UNBINDMOBILE_ERR, this.m_UnbindMobileErr);
			this.m_UnbindMobileErr = null;
		}
		private void onEventUnbindMobileOK(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.hideProgressCover();
			MMMessageBox.Show(strings.Set_Mobile_Unbind_OK, true, "确定");
			base.GoBack();
			base.GoToPage("/Source/UI/PhoneContact/PhoneNumBinding.xaml", null, false);
		}
		private void onEventUnbindMobileErr(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.hideProgressCover();
			RetConst retConst = (RetConst)evtArgs.mObject;
			string string_ = strings.Set_Mobile_Unbind_Err;
			if (retConst == RetConst.MM_ERR_UNBIND_REGBYMOBILE)
			{
				string_ = strings.Set_Mobile_Unbind_NeedQQ;
			}
			else
			{
				if (RetConst.MM_ERR_FREQ_LIMITED == retConst)
				{
					string_ = strings.Reg_PhoneNum_MsgTooFreq;
				}
			}
			MMMessageBox.Show(string_, true, "确定");
		}
		private void showProgressCover(string strCoverTitle)
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, strCoverTitle, null, false, false, null);
			this.btnViewContacts.set_IsEnabled(false);
			this.btnUnbind.set_IsEnabled(false);
		}
		private void hideProgressCover()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
			this.btnViewContacts.set_IsEnabled(true);
			this.btnUnbind.set_IsEnabled(true);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Setting/BindedMobilePage.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.ContentPanel = (Grid)base.FindName("ContentPanel");
			this.txtBindedQQ = (TextBlock)base.FindName("txtBindedQQ");
			this.btnViewContacts = (Button)base.FindName("btnViewContacts");
			this.btnUnbind = (Button)base.FindName("btnUnbind");
		}
	}
}
